package org.kjtc.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.kjtc.entity.ChargingRecord;
import org.kjtc.entity.ChargingRecordStatistics;
import org.kjtc.entity.Page;
import org.kjtc.service.ActionHistoryService;
import org.kjtc.service.CarInfoService;
import org.kjtc.service.CarTeamService;
import org.kjtc.service.ChargingRecordService;
import org.kjtc.service.ChargingStationStatisticsService;
import org.kjtc.service.DriverService;
import org.kjtc.service.LineService;
import org.kjtc.util.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class StatisticsController extends BaseController {

	@Resource(name = "chargingRecordService")
	private ChargingRecordService chargingRecordService;

	@Resource(name = "chargingStationStatisticsService")
	private ChargingStationStatisticsService chargingStationStatisticsService;

	@Resource(name = "actionHistoryService")
	private ActionHistoryService actionHistoryService;

	@Resource(name = "lineService")
	private LineService lineService;

	@Resource(name = "carInfoService")
	private CarInfoService carInfoService;

	@Resource(name = "carTeamService")
	private CarTeamService carTeamService;

	@Resource(name = "driverService")
	private DriverService driverService;

	/**
   	 * 充电记录统计
   	 */
   	@RequestMapping(value = "searchChargingRecordStatistics")
	@ResponseBody
	public Map<String, Object> searchChargingRecordStatistics(ChargingRecord chargingRecord, String page, String rows, String searchType) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计开始");

		List<ChargingRecordStatistics>chargingRecordStatistics = null;
		if(searchType != null && !searchType.isEmpty() && searchType.equals("detail")){
			chargingRecord = (ChargingRecord) this.getSession().getAttribute("searchChargingRecordStatistics");
			map.put("chargingRecord", chargingRecord);
			this.getSession().setAttribute("searchChargingRecordStatistics", null);
		}
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			if(chargingRecord.getStartChargingTime() != null && !chargingRecord.getStartChargingTime().isEmpty()){
					chargingRecord.setStartChargingDTTM(Tools.str2DateTime(chargingRecord.getStartChargingTime()));
			}
			if(chargingRecord.getEndChargingTime() != null && !chargingRecord.getEndChargingTime().isEmpty()){
				chargingRecord.setEndChargingDTTM(Tools.str2DateTime(chargingRecord.getEndChargingTime()));
			}
			chargingRecordStatistics = chargingStationStatisticsService.getChargingRecordStatistics(chargingRecord);
			this.getSession().setAttribute("searchChargingRecordStatistics", chargingRecord);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计异常" + e.getMessage());
			return map;
		}
		map.put("chargingRecordStatisticsList", chargingRecordStatistics);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询电表统计");
		chargingRecordStatistics = null;
		return map;
	}

	/**
   	 * 异常统计
   	 */
   	@RequestMapping(value = "searchAbnormalStatistics")
	@ResponseBody
	public Map<String, Object> searchAbnormalStatistics(ChargingRecord chargingRecord, String searchType) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计开始");

		List<ChargingRecordStatistics>chargingRecordStatistics = null;
		List<ChargingRecord>chargingRecordList = null;
		List<ChargingRecord>chargingRecordList2 = null;
		if(searchType != null && !searchType.isEmpty() && searchType.equals("detail")){
			chargingRecord = (ChargingRecord) this.getSession().getAttribute("searchAbnormalStatistics");
			map.put("chargingRecord", chargingRecord);
			this.getSession().setAttribute("searchAbnormalStatistics", null);
		}
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			if(chargingRecord.getStartChargingTime() != null && !chargingRecord.getStartChargingTime().isEmpty()){
				chargingRecord.setStartChargingDTTM(Tools.str2DateTime(chargingRecord.getStartChargingTime()));
			}
			if(chargingRecord.getEndChargingTime() != null && !chargingRecord.getEndChargingTime().isEmpty()){
				chargingRecord.setEndChargingDTTM(Tools.str2DateTime(chargingRecord.getEndChargingTime()));
			}
			chargingRecordStatistics = chargingStationStatisticsService.getChargingRecordStatistics(chargingRecord);
			if(chargingRecordStatistics.size() != 0){
				chargingRecordList = chargingRecordService.getLossChargingRecord(chargingRecord);
				chargingRecordList2 = chargingRecordService.getAbnormalChargingRecord(chargingRecord);
				for(ChargingRecordStatistics chargingRecord2 : chargingRecordStatistics){
					int lossCount = setLossCount(chargingRecord2.getEquipmentNo(), chargingRecordList);
					int abnormalCount = setAbnormalCount(chargingRecord2.getEquipmentNo(), chargingRecordList2);
					double abnormalChargingKWH = setAbnormalChargingKWH(chargingRecord2.getEquipmentNo(), chargingRecordList2);
					String abnormalReason = setAbnormaoReason(chargingRecord2.getEquipmentNo(), chargingRecordList2);
					chargingRecord2.setLossCount(lossCount);
					chargingRecord2.setAbnormalCount(abnormalCount);
					chargingRecord2.setAbnormalReason(abnormalReason);
					chargingRecord2.setAbnormalChargingKWH(abnormalChargingKWH);
					chargingRecord2.setAttritionRate((chargingRecord2.getBalanceAmmeterNo() - chargingRecord2.getTotalChargingKWH())/chargingRecord2.getBalanceAmmeterNo());
				}
			}
			this.getSession().setAttribute("searchAbnormalStatistics", chargingRecord);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计异常" + e.getMessage());
			return map;
		}
		map.put("chargingRecordStatisticsList", chargingRecordStatistics);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询电表统计");
		chargingRecordStatistics = null;
		return map;
	}

   	public int setLossCount(String equipmentNo, List<ChargingRecord>chargingRecordList){

   		int abnormalCount = 0;
   		for(int i = 0; i < chargingRecordList.size() -1; i++){
   			if(equipmentNo.equals(chargingRecordList.get(i).getEquipmentNo()) && equipmentNo.equals(chargingRecordList.get(i+1).getEquipmentNo()) && chargingRecordList.get(i).getStartAmmeterNo() != chargingRecordList.get(i+1).getEndAmmeterNo()){
   				abnormalCount++;
   			}
   		}
   		return abnormalCount;
   	}

   	public int setAbnormalCount(String equipmentNo, List<ChargingRecord>chargingRecordList){

   		int abnormalCount = 0;
   		for(int i = 0; i < chargingRecordList.size(); i++){
   			if(equipmentNo.equals(chargingRecordList.get(i).getEquipmentNo())){
   				abnormalCount++;
   			}
   		}
   		return abnormalCount;
   	}

   	public double setAbnormalChargingKWH(String equipmentNo, List<ChargingRecord>chargingRecordList){

   		double abnormalChargingKWH = 0;
   		for(int i = 0; i < chargingRecordList.size(); i++){
   			if(equipmentNo.equals(chargingRecordList.get(i).getEquipmentNo())){
   				abnormalChargingKWH += chargingRecordList.get(i).getTotalChargingKWH();
   			}
   		}
   		return abnormalChargingKWH;
   	}

   	public String setAbnormaoReason(String equipmentNo, List<ChargingRecord>chargingRecordList){

   		String abnormalReason = "";
   		for(int i = 0; i < chargingRecordList.size(); i++){
   			if(abnormalReason == "" && equipmentNo.equals(chargingRecordList.get(i).getEquipmentNo())){
   				abnormalReason = chargingRecordList.get(i).getAbnormalReason();
   			} else if(equipmentNo.equals(chargingRecordList.get(i).getEquipmentNo())){
   				abnormalReason = abnormalReason.concat(",").concat(chargingRecordList.get(i).getAbnormalReason());
   			}
   		}
   		return abnormalReason;
   	}
	/**
   	 * 充电记录统计详情
   	 */
   	@RequestMapping(value = "searchChargingRecordStatisticsDetail")
	@ResponseBody
	public Map<String, Object> searchChargingRecordStatisticsDetail(ChargingRecord chargingRecord, String page, String rows) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计详情开始");
		// 分页查询
		Page pageQuery = getPage();
		pageQuery.setCurrentPage(Integer.parseInt(page));
		pageQuery.setCurrentResult((Integer.parseInt(page) - 1) * (Integer.parseInt(rows)));
		pageQuery.setShowCount(Integer.parseInt(rows));

		List<ChargingRecord>chargingRecordStatisticsDetail = null;
		 try {
			 chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			 chargingRecordStatisticsDetail = chargingStationStatisticsService.getChargingRecordStatisticsDetail(chargingRecord, pageQuery);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计详情异常" + e.getMessage());
			return map;
		}
		map.put("totalCnt", pageQuery.getTotalResult());
		map.put("totalPage", pageQuery.getTotalPage());
		map.put("chargingRecordStatisticsList", chargingRecordStatisticsDetail);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询电表统计详情结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询电表统计详情");
		chargingRecordStatisticsDetail = null;
		return map;
	}

   	/**
   	 *
   	 * 充电站统计
   	 */
   	@RequestMapping(value = "searchStationTotalKWHDay")
	@ResponseBody
	public Map<String, Object> getStationTotalKWHDay(ChargingRecord chargingRecord, String page, String rows) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询站总电量开始");
		// 分页查询
		Page pageQuery = getPage();
		pageQuery.setCurrentPage(Integer.parseInt(page));
		pageQuery.setCurrentResult((Integer.parseInt(page) - 1) * (Integer.parseInt(rows)));
		pageQuery.setShowCount(Integer.parseInt(rows));

		List<ChargingRecord>stationTotalKWHDay = null;
		int totalChargingCount = 0;
		long totalChargingTime = 0l;
		float totalChargingKWHDay = 0f;
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			stationTotalKWHDay = chargingStationStatisticsService.getChargingRecordStatisticsDay(chargingRecord, pageQuery);
			for(int i=0; i<stationTotalKWHDay.size(); i++){
				totalChargingCount += stationTotalKWHDay.get(i).getChargingCountTotal();
				totalChargingTime += stationTotalKWHDay.get(i).getTotalChargingDTTM();
				totalChargingKWHDay += stationTotalKWHDay.get(i).getChargingKWHTotal();
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询站总电量异常" + e.getMessage());
			return map;
		}
		map.put("totalCnt", pageQuery.getTotalResult());
		map.put("totalPage", pageQuery.getTotalPage());
		map.put("stationTotalKWHDay", stationTotalKWHDay);
		map.put("totalChargingCount", totalChargingCount);
		map.put("totalChargingTime", totalChargingTime);
		map.put("totalChargingKWHDay", totalChargingKWHDay);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询站总电量结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询站总电量");
		stationTotalKWHDay = null;
		return map;
	}

   	/**
   	 * 单桩统计
   	 */
   	@RequestMapping(value = "searchEquipmentSingleKWHDay")
	@ResponseBody
	public Map<String, Object> searchEquipmentSingleKWHDay(ChargingRecord chargingRecord) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询单桩统计开始");

		List<ChargingRecord>equipmentSingleKWHDay = null;
		chargingRecord.setEndChargingTime(chargingRecord.getStartChargingTime());
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			equipmentSingleKWHDay = chargingRecordService.getChargingRecord(chargingRecord);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询单桩统计异常" + e.getMessage());
			return map;
		}
		map.put("equipmentSingleKWHDayList", equipmentSingleKWHDay);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询单桩统计结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询单桩统计");
		equipmentSingleKWHDay = null;
		return map;
	}

   	@RequestMapping(value = "/searchVehicleStatistics")
	@ResponseBody
	public Map<String, Object> searchVehicleStatistics(ChargingRecord chargingRecord, String page, String rows) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "车辆统计查询开始");
		// 分页
		Page pageQuery = getPage();
		pageQuery.setCurrentPage(Integer.parseInt(page));
		pageQuery.setCurrentResult((Integer.parseInt(page) - 1) * (Integer.parseInt(rows)));
		pageQuery.setShowCount(Integer.parseInt(rows));

		//查询所有设备信息
		List<ChargingRecord> vehicleRecordList;
		List<ChargingRecord> sumStatisticsList;
		List<Object> vehicleStatisticsList = null;
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			sumStatisticsList = carInfoService.getVehicleStatistics(chargingRecord);
			vehicleRecordList = carInfoService.getVehicleChargingRecord(chargingRecord, pageQuery);
			vehicleStatisticsList = new ArrayList<Object>();
			Map<String, Object> mapTotal = new HashMap<String, Object>();
			Map<String, Object> mapThis = new HashMap<String, Object>();
			for (ChargingRecord sumVehicleStatisticsInfo : sumStatisticsList) {
				mapTotal.clear();
				mapTotal.put("statisticsTypeName", "累计统计");
				mapTotal.put("chargingCountTotal", sumVehicleStatisticsInfo.getChargingCountTotal());
				mapTotal.put("chargingKWHTotal", sumVehicleStatisticsInfo.getChargingKWHTotal());
				mapTotal.put("chargingCarTotal", sumVehicleStatisticsInfo.getChargingDTTMTotal());
				vehicleStatisticsList.add(mapTotal);
				mapThis.clear();
				mapThis.put("statisticsTypeName", "本次统计");
				mapThis.put("chargingCountTotal", sumVehicleStatisticsInfo.getChargingCountDay());
				mapThis.put("chargingKWHTotal", sumVehicleStatisticsInfo.getChargingKWHDay());
				mapThis.put("chargingCarTotal", sumVehicleStatisticsInfo.getChargingDTTMDay());
				vehicleStatisticsList.add(mapThis);
			}
			map.put("totalCnt",  pageQuery.getTotalResult());
			map.put("totalPage", pageQuery.getTotalPage());
			map.put("vehicleStatisticsList", vehicleStatisticsList);
			map.put("vehicleRecordList", vehicleRecordList);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "车辆统计查询异常" + e.getMessage());
			return map;
		}
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "车辆统计查询结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "车辆统计查询");
		vehicleRecordList = null;
		sumStatisticsList = null;
		return map;
	}

   	/**
   	 * 线路统计
   	 */
   	@RequestMapping(value = "searchLineStatistics")
	@ResponseBody
	public Map<String, Object> searchLineStatistics(ChargingRecord chargingRecord, String page, String rows) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询线路统计开始");
		// 分页查询
		Page pageQuery = getPage();
		pageQuery.setCurrentPage(Integer.parseInt(page));
		pageQuery.setCurrentResult((Integer.parseInt(page) - 1) * (Integer.parseInt(rows)));
		pageQuery.setShowCount(Integer.parseInt(rows));

		List<ChargingRecord>lineRecordList = null;
		List<ChargingRecord> sumStatisticsList;
		List<Object> lineStatisticsList = null;
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			sumStatisticsList = lineService.getLineStatistics(chargingRecord);
			lineRecordList = lineService.getLineChargingRecord(chargingRecord, pageQuery);
			lineStatisticsList = new ArrayList<Object>();
			Map<String, Object> mapTotal = new HashMap<String, Object>();
			Map<String, Object> mapThis = new HashMap<String, Object>();
			for (ChargingRecord sumLineStatisticsInfo : sumStatisticsList) {
				mapTotal.clear();
				mapTotal.put("statisticsTypeName", "累计统计");
				mapTotal.put("chargingCountTotal", sumLineStatisticsInfo.getChargingCountTotal());
				mapTotal.put("chargingKWHTotal", sumLineStatisticsInfo.getChargingKWHTotal());
				mapTotal.put("chargingCarTotal", sumLineStatisticsInfo.getChargingDTTMTotal());
				lineStatisticsList.add(mapTotal);
				mapThis.clear();
				mapThis.put("statisticsTypeName", "本次统计");
				mapThis.put("chargingCountTotal", sumLineStatisticsInfo.getChargingCountDay());
				mapThis.put("chargingKWHTotal", sumLineStatisticsInfo.getChargingKWHDay());
				mapThis.put("chargingCarTotal", sumLineStatisticsInfo.getChargingDTTMDay());
				lineStatisticsList.add(mapThis);
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询线路统计异常" + e.getMessage());
			return map;
		}
		map.put("totalCnt", pageQuery.getTotalResult());
		map.put("totalPage", pageQuery.getTotalPage());
		map.put("lineStatisticsList", lineStatisticsList);
		map.put("lineRecordList", lineRecordList);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询线路统计结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询线路统计");
		lineRecordList = null;
		sumStatisticsList = null;
		return map;
	}

   	/**
   	 * 车队统计
   	 */
   	@RequestMapping(value = "searchCarTeamStatistics")
	@ResponseBody
	public Map<String, Object> searchCarTeamStatistics(ChargingRecord chargingRecord, String page, String rows) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询线路统计开始");
		// 分页查询
		Page pageQuery = getPage();
		pageQuery.setCurrentPage(Integer.parseInt(page));
		pageQuery.setCurrentResult((Integer.parseInt(page) - 1) * (Integer.parseInt(rows)));
		pageQuery.setShowCount(Integer.parseInt(rows));

		List<ChargingRecord>carTeamRecordList = null;
		List<ChargingRecord> sumStatisticsList;
		List<Object> carTeamStatisticsList = null;
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			sumStatisticsList = carTeamService.getCarTeamStatistics(chargingRecord);
			carTeamRecordList = carTeamService.getCarTeamChargingRecord(chargingRecord, pageQuery);
			carTeamStatisticsList = new ArrayList<Object>();
			Map<String, Object> mapTotal = new HashMap<String, Object>();
			Map<String, Object> mapThis = new HashMap<String, Object>();
			for (ChargingRecord sumCarTeamStatisticsInfo : sumStatisticsList) {
				mapTotal.clear();
				mapTotal.put("statisticsTypeName", "累计统计");
				mapTotal.put("chargingCountTotal", sumCarTeamStatisticsInfo.getChargingCountTotal());
				mapTotal.put("chargingKWHTotal", sumCarTeamStatisticsInfo.getChargingKWHTotal());
				mapTotal.put("chargingCarTotal", sumCarTeamStatisticsInfo.getChargingDTTMTotal());
				carTeamStatisticsList.add(mapTotal);
				mapThis.clear();
				mapThis.put("statisticsTypeName", "本次统计");
				mapThis.put("chargingCountTotal", sumCarTeamStatisticsInfo.getChargingCountDay());
				mapThis.put("chargingKWHTotal", sumCarTeamStatisticsInfo.getChargingKWHDay());
				mapThis.put("chargingCarTotal", sumCarTeamStatisticsInfo.getChargingDTTMDay());
				carTeamStatisticsList.add(mapThis);
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询线路统计异常" + e.getMessage());
			return map;
		}
		map.put("totalCnt", pageQuery.getTotalResult());
		map.put("totalPage", pageQuery.getTotalPage());
		map.put("carTeamStatisticsList", carTeamStatisticsList);
		map.put("carTeamRecordList", carTeamRecordList);
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "查询线路统计结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "查询线路统计");
		carTeamRecordList = null;
		sumStatisticsList = null;
		return map;
	}

   	@RequestMapping(value = "/searchDriverStatistics")
	@ResponseBody
	public Map<String, Object> searchDriverStatistics(ChargingRecord chargingRecord) {

   		Map<String, Object> map = new HashMap<String, Object>();
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "驾驶员统计查询开始");

		//查询所有设备信息
		List<ChargingRecord> driverRecordList;
		List<ChargingRecord> sumStatisticsList;
		List<Object> driverStatisticsList = null;
		try {
			chargingRecord.setBranchCompanyID(this.getBranchCompanyID());
			sumStatisticsList = driverService.getDriverStatistics(chargingRecord);
			driverRecordList = driverService.getDriverChargingRecord(chargingRecord);
			driverStatisticsList = new ArrayList<Object>();
			Map<String, Object> mapTotal = new HashMap<String, Object>();
			Map<String, Object> mapThis = new HashMap<String, Object>();
			for (ChargingRecord sumVehicleStatisticsInfo : sumStatisticsList) {
				mapTotal.clear();
				mapTotal.put("statisticsTypeName", "累计统计");
				mapTotal.put("chargingCountTotal", sumVehicleStatisticsInfo.getChargingCountTotal());
				mapTotal.put("chargingKWHTotal", sumVehicleStatisticsInfo.getChargingKWHTotal());
				mapTotal.put("chargingCarTotal", sumVehicleStatisticsInfo.getChargingDTTMTotal());
				driverStatisticsList.add(mapTotal);
				mapThis.clear();
				mapThis.put("statisticsTypeName", "本次统计");
				mapThis.put("chargingCountTotal", sumVehicleStatisticsInfo.getChargingCountDay());
				mapThis.put("chargingKWHTotal", sumVehicleStatisticsInfo.getChargingKWHDay());
				mapThis.put("chargingCarTotal", sumVehicleStatisticsInfo.getChargingDTTMDay());
				driverStatisticsList.add(mapThis);
			}
			map.put("driverStatisticsList", driverStatisticsList);
			map.put("driverRecordList", driverRecordList);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "驾驶员统计查询异常" + e.getMessage());
			return map;
		}
		logger.info(this.getUesrInfo().getUserName() + "(" + this.getUesrInfo().getUserID() + ")：" + "驾驶员统计查询结束");
		actionHistoryService.saveActionHistory(this.getUesr().getUserID(), "驾驶员统计查询");
		driverRecordList = null;
		sumStatisticsList = null;
		return map;
	}
}
